package com.chrray.position.domain;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.chrray.position.enums.app.FdUserRoleEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import com.baomidou.mybatisplus.annotation.*;

/**
 * 首页广告配置表 对象
 *
 * @author wusiwee
 * @email wusiwee@163.com
 * @since 1.0.1 2024-08-07
 */

@Data
@ApiModel(description = "首页广告配置表")
@TableName("fd_home_ad")
public class FdHomeAd extends Model<FdHomeAd> {
	@ApiModelProperty(value = "主键ID")
	@TableId(type = IdType.AUTO)
	private Long id;

	@ApiModelProperty(value = "名称")
	private String name;

	@ApiModelProperty(value = "位置: 0-雇工首页, 1-雇主首页")
	private Integer position;

	@ApiModelProperty(value = "图片地址")
	private String imageUrl;

	@ApiModelProperty(value = "状态")
	private Integer status;

	private Integer delFlag;

	public FdHomeAd findLatestOne(Integer currentRole) {
		return new FdHomeAd().selectOne(new QueryWrapper<FdHomeAd>().eq("position",currentRole).orderByDesc("id").last("limit 1"));
	}

}
